﻿using mscook.core.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Linq;

namespace mscook.core.repositories
{
    public class ResourceBonusSettingRepository : Repository<ResourceBonusSetting>, IResourceBonusSettingRepository
    {
        public ResourceBonusSetting SelectByResourceId(string resourceId)
        {
            return (from x in this.Session.Query<ResourceBonusSetting>() select x).
                Where(o => o.ResourceID == resourceId).SingleOrDefault();
        }

        public IList<ResourceBonusSetting> SelectByResourceIds(IList<string> resourceIds)
        {
            return (from x in this.Session.Query<ResourceBonusSetting>() select x).
                Where(o => resourceIds.Contains(o.ResourceID)).ToList();
        }
    

        public IList<ResourceBonusSetting> SelectByAriticKey(string year, string month)
        {
            return (from x in this.Session.Query<ResourceBonusSetting>() select x).
                Where(o => o.ResourceID.Contains(year+month)).ToList();
        }

        public IList<ResourceBonusSetting> SelectByAriticKeyAndType(string year, string month, PurchasedCategory purchasedCategory)
        {
            return (from x in this.Session.Query<ResourceBonusSetting>() select x).
                Where(o => o.ResourceID.Contains(year + month)
                &&o.PurchasedCategory==purchasedCategory
                
                ).ToList();
        }
    }
}
